﻿using System;
using Myotragus.Data.Domain;
using Myotragus.Data.Metadata;
using Myotragus.Data.Util;

namespace Myotragus.Data.Emit
{
	public class DefaultsSaveEntityGenerator : SaveEntityGenerator,
		IDefaultsSaveEntityGenerator
	{
		protected static readonly Type TypeOfDefaultsLocalizableText = 
			typeof(DefaultsSaveLocalizableText);

		public DefaultsSaveEntityGenerator(IDynamicAssembly dynamicAssembly,
			INameGenerator nameGenerator, ILocalizableEntityMapping mapping)
			: base(dynamicAssembly, nameGenerator, mapping)
		{
		}

		protected static readonly Type TypeOfIDefaultsSaveEntity = typeof(IDefaultsSaveEntity<,>);

		protected override Type BaseInterfaceType
		{
			get { return TypeOfIDefaultsSaveEntity; }
		}

		protected override void AttachLocalizableProperty(IDynamicType type, string name)
		{
			type.DefineAutomaticProperty(name, TypeOfDefaultsLocalizableText);
		}
	}
}